home *** CD-ROM | disk | FTP | other *** search
- Path: dfw.dfw.net!not-for-mail
- From: ftlgeuse@dfw.dfw.net (Fetelgeuse)
- Newsgroups: comp.lang.c
- Subject: Re: Hiding a password
- Date: 4 Mar 1996 10:46:37 GMT
- Organization: DFW Internet Services - DFWNet: 800-2-DFWNet
- Message-ID: <4hehmd$1fr@fnord.dfw.net>
- References: <1996Feb29.224936.137160@forest> <4he620$qf2@hpbblb.bbn.hp.com>
- NNTP-Posting-Host: dfw.dfw.net
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Matthias Dittrich (matti) wrote:
- : ebromber@forest.drew.edu wrote:
- : >I recently wrote a password program. However, there is one little flaw I
- : >want to fix. When the password is entered, it is visible on the screen. I
- : >was wondering if anyone knows how to hide the password by printing
- : >asterisks instead of the actual character.
- : >Thanks in advance.
- : >
- : Switch echo off using ioctl function and if you want so, write asterisks
- : on your terminal.
- :
- : Good luck,
- : Matthias
- :
- I wrote a function to do precisely the same thing. I made a function
- something like:
- char * GetString_NoEcho()
- {
- char *temp;
- int i=1;
- while(temp[i-1]!=13) {
- temp[i-1]=getch();
- i++;
- }
- temp[i]=0;
- }
- I haven't really thought that out real well so you might find that the
- string index is the wrong value for any given character position but that
- would be easily fixed (if it is off, it would be off by 1 position) What
- it should do is place the return value of a series of getch()'s into temp[0],
- temp[1],temp[...], until the user enters [enter] and then where enter was
- gets replaced by a null. Anyway, like I said the indexes may be off but
- this way works when done properly.
-
-